-
-
Notifications
You must be signed in to change notification settings - Fork 492
Description
Summary
In my project, VS Code successfully loads my Prettier config, but when I try and format a tsx
file it logs an error. Visual Studio Code is on version 1.80.2.
My config is as follows, and is exported as a package in a monorepo and used in the root of the monorepo (it seems to be loading successfully).
export default {
plugins: ["prettier-plugin-organize-imports", "prettier-plugin-tailwindcss"],
tailwindFunctions: ["cva"],
singleQuote: false,
};
Steps To Reproduce:
- Use VS Code 1.80.2
- Set up a Turborepo project
- Make a package called
prettier-config
and export the config - List packages
"prettier": "^3.0.0",
,"prettier-plugin-organize-imports": "^3.2.3",
and"prettier-plugin-tailwindcss": "^0.4.1"
as peerDependencies. - Make sure the VS Code plugin is set up correctly
- Try formatting a React TSX file using Prettier from the command palette
Expected result
The files should be formatted
Actual result
I get a pop up with the error.
Command 'Format Document With...' resulted in an error
Error resolve node module 'prettier-plugin-organize-imports'
I have tried multiple steps including removing plugins one at a time (same result for them all) as well as repositioning my prettier config and taking it out of the monorepo structure. I have tried require, import as well as pure text plugin definition based on the official docs as well as tried both esm and commonjs exports for the config.
I appreciate between Prettier and Prettier VS Code there are a fair few related issues, but on the off chance this bug report is useful I thought it would be worth posting.
Additional information
package.json of the prettier-config package:
"name": "prettier-config",
"version": "0.0.0",
"main": "./index.js",
"exports": {
".": "./index.js"
},
"type": "module",
"engine": {
"node": ">=16.0.0"
},
"peerDependencies": {
"prettier": "^3.0.0",
"prettier-plugin-organize-imports": "^3.2.3",
"prettier-plugin-tailwindcss": "^0.4.1"
}
}
VS Code Version:
Version: 1.80.2 (Universal)
Commit: 2ccd690cbff1569e4a83d7c43d45101f817401dc
Date: 2023-07-27T21:05:41.366Z
Electron: 22.3.14
ElectronBuildId: 22695494
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Darwin arm64 23.0.0
Prettier Extension Version: v10.1.0
OS and version: macOS 14.0 Beta (23A5276g)
Prettier Log Output
["ERROR" - 18:34:42] Error handling text editor change
["ERROR" - 18:34:42] Error resolve node module 'prettier-plugin-organize-imports'
Error: Error resolve node module 'prettier-plugin-organize-imports'
at n (/Users/lewisflude/.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:2718)
at /Users/lewisflude/.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:3068
at Array.map (<anonymous>)
at t.resolveConfigPlugins (/Users/lewisflude/.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:3003)
at t.ModuleResolver.resolveConfig (/Users/lewisflude/.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:7290)
at t.default.getSelectors (/Users/lewisflude/.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:11562)
at t.default.handleActiveTextEditorChanged (/Users/lewisflude/.vscode/extensions/esbenp.prettier-vscode-10.1.0/dist/extension.js:1:10924)
["INFO" - 18:34:44] Formatting file:///Users/lewisflude/Code/redacted/packages/ui/src/components/DataGrid/DataGrid.tsx
["INFO" - 18:34:44] Using config file at '/Users/lewisflude/Code/redacted/package.json'```